import request from '@/utils/request'

// 订单结算确认
// mode: cart => obj { cartIds }
// mode: buyNow  => obj { goodsId  goodsNum  goodsSkuID
export const checkOrder = (mode, obj) => {
  return request.get('/checkout/order', {
    params: {
      mode,   // cart  buyNow
      delivery: 0,   // 配送方式
      couponId: 0,   // 优惠券id   0为不使用优惠券
      isUsePoints: 0,  // 是否使用积分
      ...obj   // 将传递过来的参数对象  动态展开
    }
  })
}

// 提交订单
// mode: cart => obj { cartIds }
// mode: buyNow  => obj { goodsId  goodsNum  goodsSkuID
export const submitOrder = (mode, obj) => {
  return request.post('/checkout/submit', {
    mode,
    delivery: 10,  // 快递配送
    couponId: 0,
    isUsePoints: 0,
    payType: 10,   // 支付方式： 余额支付
    ...obj
  })
}

// 订单列表
export const getMyOrderList = (dataType, page) => {
  return request.get('/order/list', {
    params: {
      dataType,
      page
    }
  })
}